<%@tag pageEncoding="UTF-8"%>
<%@ attribute name="page" type="com.github.miemiedev.mybatis.paginator.domain.Paginator" required="true"%>
<%@ attribute name="isShowPageLength" type="java.lang.Boolean" required="false"%>
<%@ attribute name="target" type="java.lang.String" required="false"%>
<%@ attribute name="isShowPageInfo" type="java.lang.Boolean" required="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%
if(target == null || "".equals(target)){
	target = "listDiv";
}
Integer[] siders = page.getSlider();
int current = page.getPage();
int limit = page.getLimit();
request.setAttribute("siders", siders);
request.setAttribute("current", current);
request.setAttribute("limit", limit);
request.setAttribute("target", target);
%>

<% if(isShowPageInfo != null && isShowPageInfo) {%>
	<div class="dataTables_info">显示[<%= page.getStartRow()%>]到[<%= page.getEndRow()%>]条数据，总共[<%=page.getTotalCount()%>]条数据,当前第[<%=page.getPage() %>/<%=page.getTotalPages() %>]页</div>
<%} %>

<%if(isShowPageLength != null && isShowPageLength) {%>
	<div class="dataTables_length">
		<label>显示<select class="form-control input-sm" onchange="javascript:setLimit(this.value,'${target}')">
			<option value="10" <c:if test="${limit == 10}">selected</c:if>>10</option>
			<option value="20" <c:if test="${limit == 20}">selected</c:if>>20</option>
			<option value="50" <c:if test="${limit == 50}">selected</c:if>>50</option>
			<option value="100" <c:if test="${limit == 100}">selected</c:if>>100</option>
		</select>&nbsp;条数据</label>
	</div>
<%} %>

<div class="dataTables_paginate paging_full_numbers">
   	<ul class="pagination pagination-active-dark">
   	   <%if(page.isFirstPage()){ %>
   			<li class="paginate_button first disabled" tabindex="0"><a href="javascript:void(0);">首页</a></li>
   		<%}else{%>
   			<li class="paginate_button first" tabindex="0"><a href="javascript:void(0);" onclick="javascript:setPage(1,'${target}');">首页</a></li>
   		<%} %>
   		<%if(page.isHasPrePage()){ %>
   			<li class="paginate_button previous" tabindex="0"><a href="javascript:void(0);">上一页</a></li>
   		<%}else{%>
   			<li class="paginate_button previous disabled" tabindex="0"><a href="javascript:void(0);" onclick="javascript:setPage(${current}-1,'${target}');">上一页</a></li>
   		<%} %>
   		<c:forEach var="i" items="${siders}">
            <c:choose>
                <c:when test="${i == current}">
                	<li class="paginate_button active disabled" tabindex="0"><a href="javascript:void(0);">${i}</a></li>
                </c:when>
                <c:otherwise>
                    <li class="paginate_button " tabindex="0"><a href="javascript:setPage(${i},'${target}');">${i}</a></li>
                </c:otherwise>
            </c:choose>
        </c:forEach>
   		<%if(page.isHasNextPage()) {%>
   			<li class="paginate_button next" tabindex="0"><a href="javascript:void(0);" onclick="javascript:setPage(${current}+1,'${target}');">下一页</a></li>
   	    <%} else {%>
   	    	<li class="paginate_button next disabled" tabindex="0"><a href="javascript:void(0);">下一页</a></li>
   	    <%} %>
   	    <%if(page.isLastPage()) {%>
   		    <li class="paginate_button last disabled" tabindex="0"><a href="javascript:void(0);">尾页</a></li>
   		<%}else{%>
   			<li class="paginate_button last" tabindex="0"><a href="javascript:void(0);" onclick="javascript:setPage(<%=page.getTotalPages() %>,'${target}');">尾页</a></li>
   		<%} %>
   	</ul>
</div>
